package com.wyix.service;

import com.wyix.model.Coffee;
import com.wyix.model.CoffeeMaker;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author wangdx
 * @since 2025/8/6
 */
public class BaristaConstructor {
    private final CoffeeMaker coffeeMaker; // 不可变依赖

    // 构造器注入（@Autowired可选，Spring 4.3+ 单参构造器可省略）
    @Autowired
    public BaristaConstructor(CoffeeMaker coffeeMaker) {
        this.coffeeMaker = coffeeMaker;
    }

    public String serveCoffee() {
        return "咖啡师使用构造器注入的机器：" + coffeeMaker.makeCoffee();
    }

    public Coffee makeCoffee() {
        return coffeeMaker.make();
    }
}
